import styled from "@emotion/styled"
import { PageHeader } from "../../AccountPage/components/PageHeader"
import { activeCategoryAtom, categoryTitleAtom } from "../atom"
import { useAtom } from "jotai"
import { useEffect } from "react"
import Introduce from "../components/Introduce"
import Certificate from "../components/Certificate"
import Followus from "../components/FollowUs"

const AboutContainer = styled.div`
    width: 375rem;
    /* background-color: #ffffff; */
    position: fixed;
    top: 0;
    z-index: 10;
    height: 100vh;
    /* width: 100%; */
    background:
        linear-gradient(0deg, #ebf3ff, #ebf3ff),
        radial-gradient(
            136.79% 100% at 100% 0%,
            rgba(255, 184, 219, 0.4) 0%,
            rgba(255, 255, 255, 0) 100%
        ),
        radial-gradient(
            100% 61.68% at 0% 100%,
            rgba(179, 255, 204, 0.16) 0%,
            rgba(255, 255, 255, 0) 100%
        );
`

const AboutTabs = styled.div`
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28rem;
`

interface isActive {
    isActive: boolean
}

const CategoryTab = styled.div<isActive>`
    font-family: "Gilroy";
    font-weight: ${(props) => (props.isActive ? 700 : 500)};
    width: 50%;
    font-size: 16rem;
    color: ${(props) => (props.isActive ? "#000000" : "#69728C")};
    position: relative;
    cursor: pointer;
    text-align: center;
    padding-bottom: 4rem;
    margin-top: 8rem;
    &::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: ${(props) => (props.isActive ? "24rem" : "0")};
        height: 2rem;
        background-color: #ff2d55;
        transition: width 0.3s ease;
    }
`

export default function AboutUsPage() {
    const [activeCategoryIndex, setActiveCategoryIndex] = useAtom(activeCategoryAtom)
    const [categoryTitle, setCategoryTitle] = useAtom(categoryTitleAtom)

    useEffect(() => {
        setCategoryTitle([{ title: "Introduce" }, { title: "Follow Us" }])
    }, [setCategoryTitle])
    return (
        <AboutContainer>
            <PageHeader
                title="About Us"
                backPath="/my"
                iconType="black-arrow"
                textColor="#131416"
                backgroundColor="transparent"
            />
            <AboutTabs>
                {categoryTitle.map((category, index) => (
                    <CategoryTab
                        key={index}
                        isActive={activeCategoryIndex === index}
                        onClick={() => setActiveCategoryIndex(index)}
                    >
                        {category.title}
                    </CategoryTab>
                ))}
            </AboutTabs>
            {activeCategoryIndex === 0 ? <Introduce /> : <Followus />}
        </AboutContainer>
    )
}
